import Page
from Page import Yomi
from Base.Base import Base
from selenium.webdriver.common.by import By


class YomiTemperaturePage(Base):
    """
    语音训练温度调节

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 温度列表标题
        self.temperature_list_title_text = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format("tv_title"))

        # 当前温度
        self.temperature_display_text = (By.XPATH, Yomi.temperature_display_text.format(""))

        # 确认按钮
        self.temperature_ok_btn = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format("tv_sure"))

        # 取消按钮
        self.temperature_no_btn = (By.XPATH, Yomi.RESOURCE_ID_Assistant.format("tv_cancel"))

    def get_list_title(self):
        """
        获取yomi技能列表标题

        :return:获取元素
        """
        return self.find_element_o(self.temperature_list_title_text)

    def get_display(self, index=1):
        """
        获取温度显示

        :return:获取元素
        """
        self.temperature_display_text = (By.XPATH, Yomi.temperature_display_text.format(index))
        return self.find_element_o(self.temperature_display_text)

    def click_ok(self):
        """
        点击ok按钮

        :return:None
        """
        self.click_element(self.temperature_ok_btn)

    def click_no(self):
        """
        点击取消按钮

        :return:None
        """
        self.click_element(self.temperature_no_btn)

    def swipe_temperature_list(self):
        """
        滑动温度列表

        :return:None
        """
        self.swipe_o(location=(966, 966, 333, 463), direction='up')

    def is_display_yomi_temperature(self):
        """
        查看是否进入温度页

        :return:
        """
        return self.is_display(self.temperature_list_title_text)
